package OpenFile;

import java.awt.Desktop;
import java.io.File;
 
//Cross platform solution to view a PDF file
public class OpenFile {
 
	public void openFile(String path) {
		
		  try {
	 
			File File = new File(path);
			if (File.exists()) {
	 
				if (Desktop.isDesktopSupported()) {
					Desktop.getDesktop().open(File);
				} else {
					System.out.println("Awt Desktop is not supported!");
				}
	 
			} else {
				System.out.println("File doesn't exist!");
			}
	 
			System.out.println("Done");
	 
		  } catch (Exception ex) {
			ex.printStackTrace();
		  }
	 
		}
	
//	public static void main(String[] args) {
// 
//	  try {
// 
//		File File = new File("c:\\Joyful stories November.docx");
//		if (File.exists()) {
// 
//			if (Desktop.isDesktopSupported()) {
//				Desktop.getDesktop().open(File);
//			} else {
//				System.out.println("Awt Desktop is not supported!");
//			}
// 
//		} else {
//			System.out.println("File is not exists!");
//		}
// 
//		System.out.println("Done");
// 
//	  } catch (Exception ex) {
//		ex.printStackTrace();
//	  }
// 
//	}
}